//
//  LoadData.m
//  大轮胎
//
//  Created by 刘恪纲 on 2017/3/23.
//  Copyright © 2017年 zyc. All rights reserved.
//

#import "LoadData.h"
#import "YCNetWork.h"
#import <YYModel.h>
#import "Model.h"
#import <AFNetworking.h>
#define URL @"http://lscy4.caeac.com.cn/api/product_fenlei.php?appkey=1138"

static LoadData * ld = nil;
@implementation LoadData
{
    Model * mo;
}
+(instancetype)shardData
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        ld = [[LoadData alloc]init];
    });
    return  ld;
}



-(void)getMessage
{
    [YCNetWork getWithURLString:URL parameters:self success:^(NSDictionary *data) {
        
       NSMutableArray *arrData  = [[NSMutableArray alloc]init];
      //  NSLog(@"%@",data);
        for (NSArray * arr in data)
        {
            mo = [Model yy_modelWithJSON:arr];
            [arrData addObject:mo];
           // NSLog(@"111%@",arrData);
        }
        
        [[NSNotificationCenter defaultCenter]postNotificationName:@"a" object:arrData];
        
    } failure:^(NSError *error) {}];
}
-(void)getMessageOne:(NSString*)ids
{
    [YCNetWork getWithURLString:[NSString stringWithFormat:@"http://lscy4.caeac.com.cn/api/product.php?appkey=1138&tid=%@&sort=0&page=0",ids] parameters:self success:^(NSDictionary *data) {
        
        
        NSMutableArray * arrData = [[NSMutableArray alloc]init];
        NSArray * arr = [data objectForKey:@"product"];
       // NSLog(@"====%@",arr);
        for (NSDictionary * dic  in arr)
        {
            Model_One * moOne = [Model_One yy_modelWithJSON:dic];
            [arrData addObject:moOne];
            
        }
        [[NSNotificationCenter defaultCenter]postNotificationName:@"b" object:arrData];
        
    } failure:^(NSError *error) {
        
        
    }];
}

@end
